import defaultImg from '@/components/defaultImg/defaultImg'
export default {
  components: {
    defaultImg
  },
  data(){
    return {
      store: {},
      history: [],
      loadStatus: ''
    }
  },
  created(){
    this.store = uni.getStorageSync('userInfoDetail').store
    this.role = this.$store.state.user.userInfo.role
    this.getHistoryDateOfReport()
  },
  methods: {
    clickLoadMore(){
      this.getHistoryDateOfReport()
    },
    returnTime(time) {
      if (time) {
        return time.split('T')[0] + ' ' + time.split('T')[1]
      }
    },
    // 加载前、中、后
    moreStatus(status) {
		  this.loadStatus = status
    },
    // 历史日报
    async getHistoryDateOfReport(){
      uni.showLoading({
        title: '加载中'
      })
			 let storeId = uni.getStorageSync('userInfoDetail').store.storeId
      try{
        let data = {
          'pageIndex': 1,
          'pageSize': 10,
          'store_Id': storeId
        }
        const res = await this.$api.banner.getHistoryDateOfReport(data)
        // this.history = res.data.list
        this.history = [...this.history, ...res.data.list]
        if (res.data.total <= 10) {
				  this.loadStatus = 'nomore'
        } else {
				  this.moreStatus(res.data.list.length !== 0 ? 'loadmore' : 'nomore')
        }

        // this.moreStatus(res.data.list.length !== 0 ? 'loadmore' : 'nomore')
        uni.hideLoading()
        if (this.history.length === 0){
				  return false
        }
      }catch(e){
        //TODO handle the exception
      }
    },

    goPage(url){
      uni.navigateTo({
        url: url
      })
    },
    goMargin() {
		  console.log(1111)
		  uni.navigateTo({
		    url: '/pages_common/pages_me/margin/margin',
		  })
    },
  },
}